package com.xuecheng.manage_cms.controller;

import com.xuecheng.api.CmsSiteControllerApi;
import com.xuecheng.framework.domain.cms.CmsSite;
import com.xuecheng.framework.domain.cms.CmsSiteServer;
import com.xuecheng.framework.domain.cms.request.QuerySiteRequest;
import com.xuecheng.framework.domain.cms.response.SiteResult;
import com.xuecheng.framework.domain.cms.response.SiteServerResult;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_cms.service.CmsSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cms/site")
public class CmsSiteController implements CmsSiteControllerApi {
    @Autowired
    CmsSiteService cmsSiteService;

    @Override
    @GetMapping("/findList/{page}/{size}")
    public QueryResponseResult findList(@PathVariable("page") int page,@PathVariable("size") int size, QuerySiteRequest siteRequest) {
        return cmsSiteService.findList(page,size,siteRequest);
    }

    @Override
    @PostMapping("/add")
    public SiteResult add(@RequestBody CmsSite cmsSite) {
        return cmsSiteService.add(cmsSite);
    }

    @Override
    @GetMapping("/findById/{id}")
    public CmsSite findById(@PathVariable("id") String id) {
        return cmsSiteService.findById(id);
    }

    @Override
    @PutMapping("/edit/{id}")
    public SiteResult edit(@PathVariable("id") String id,@RequestBody CmsSite cmsSite) {
        return cmsSiteService.edit(id,cmsSite);
    }

    @Override
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") String id) {
        return cmsSiteService.delete(id);
    }
}
